<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import = "javax.servlet.http.HttpSession" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.css">
<title>Purchase</title>

</head>
	<body>
		<script type="text/javascript"> src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
		<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>  
		<script>
  				$(document).ready(function() {
    				$("#datepicker").datepicker();
 				 });

				function stopRKey(evt) { 
  					var evt = (evt) ? evt : ((event) ? event : null); 
  					var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 
  					if (evt.keyCode == 13)  {return false;} 
					} 
				document.onkeypress = stopRKey; 

				function calculate_net(){
				var grossweight = document.getElementById("grossweight").value;
				var tareweight = document.getElementById("tareweight").value;
				
				if (grossweight > tareweight){
	
	var netweight = grossweight - tareweight;
	document.getElementById("netweight").value = netweight;
	}
	else {
		alert("Grossweight must be greater than tareweight");
	}
}

</script>

<% 
		String un = (String) session.getAttribute("name");
		if(un!=null){ %>
		
		<nav class="navbar navbar-default navbar-fixed-top " role="navigation">
		<div class="container-fluid">
		<div class="navbar-header">
		<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      </div>	
   
   <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav navbar-right">
      <li><a href="UserPanel.jsp">Home</a></li>
      <li><a href="LogOut">LogOut</a></li>
      </ul></div>
		</nav><br><br><br>
		
		<div class="container">

    	
    	<h2 class="text-center login-title" >EZRiceMillSystem</h2>
    	<div class="col-sm-2 col-md-4 col-md-offset-4">
	<h4 class="text-center login-title">Welcome User</h4>
	</div></div>
  		
  		<div class=" col-md-4 col-md-offset-4">
  <div class="well">
  
    
     
        <fieldset>
          <legend>Purchase</legend>
    		
<style>
	.navbar-header {
    float: left;
    padding: 5px;
    text-align: center;
    width: 95%;
}
.navbar-brand {float:none;}	
</style>

<div class="control-group">

  <label class="control-label">Select a Rice Mill</label>
  <div class="controls">
              <div class="row-fluid">
                <div class="span9">
                <form name="Purchase form" action ="Purchase" method="post">
                  <select class="input-block-level" name="Rice Mill">
                  <option value="Selection">---- Please select ----</option>
                    <option value="Ramsar Rice & General Mills">Ramsar Rice & General Mills</option>
    				<option value="Ramsar Rice Mills Pvt. Ltd.">Ramsar Rice Mills Pvt. Ltd.</option>
    				<option value="Kwality Rice Mills Pvt. Ltd.">Kwality Rice Mills Pvt. Ltd.</option>
                  </select>
                </div>
                </div>
                </div>
                
 				<label class="control-label">Select an Agency</label>
  				<div class="controls">
              <div class="row-fluid">
                <div class="span9">
                  <select class="input-block-level" name="Agency">
 	 				<option value="Selection">---- Please select ----</option>
    				<option value="Agency1">Agency1</option>
    				<option value="Agency2">Agency2</option>
    				<option value="Agency3">Agency3</option>
    				<option value="Agency4">Agency4</option>
    				<option value="Agency5">Agency5</option>
    				<option value="Agency6">Agency6</option>
  				  </select>
				 </div>
                </div>
 				 </div>
 				 
 <div class="control-group">
  <label class="control-label">Date</label>
  <div class="controls">
<input type = "date" id="datepicker" name="purchasedate">
</div></div>


<div class="control-group">
  <label class="control-label">GrossWeight</label>
  <div class="controls">           
 <input  id = "grossweight" value="grossweight" name="grossweight" onchange="calculate_net()">
 </div></div>

<div class="control-group">
  <label class="control-label">TareWeight</label>
  <div class="controls">  
<input  id ="tareweight" value="tareweight" name="tareweight" onchange="calculate_net()">
</div></div>
<div class="control-group">
  <label class="control-label">NetWeight</label>
  <div class="controls">
<input id = "netweight" value="netweight" name="netweight">
</div></div><br>

<button class="btn btn-lg btn-primary btn-block" type="submit">
				Add</button>
</form><%}
else{  
	out.println("<script type=\"text/javascript\">");
	   out.println("alert('Please login first');");
	   out.println("location='index.jsp';");
	   out.println("</script>");
			//out.print("Please login first");    
            //request.getRequestDispatcher("index.jsp").include(request, response);  
        } 
        %>
        </div>
         </div>
          </div>
           </div>
            </div>
             </div>
             <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>

</body>
</html>